import * as actionTypes from "./constants";

import { getPlaylistDynamic } from "@/services/song";
import { getComment } from "@/services/comment";

const playlistAction = (res) => ({
  type: actionTypes.GETPLAYLISTCONTENT,
  playlists: res,
});

const playlistCommentAction = (res) => ({
  type: actionTypes.GETPLAYLISTCOMMENT,
  playlistComment: res,
});

export const getPlaylistXq = (id) => {
  return (dispatch) => {
    getPlaylistDynamic(id).then((res) => {
      dispatch(playlistAction(res));
    });
  };
};

export const getPlaylistComment = (id, limit, offset, before) => {
  return (dispatch) => {
    getComment(id, limit, offset, before).then((res) => {
      dispatch(playlistCommentAction(res));
    });
  };
};
